<template>
	<view>
<!-- 		<uni-data-select v-model="goodsType" :localdata="range" @change="change"></uni-data-select> -->
		<!-- 商品列表区 -->
		<view>
			
			<uni-section v-for="item in goodsList" :key="item.id" :title="item.title" type="line">
						<uni-card :title="item.description" :sub-title='formatCurrency(item.price)'  :thumbnail="JSON.parse(item.images)[0]" :is-shadow="false">
							<text class="uni-body">{{item.description}}</text>
						</uni-card>
					</uni-section>
		</view>
	</view>
</template>

<script>
	import {
		getMyGoodsList,
		getGoodsCategories,
	} from '@/api/goods'
	
	export default {
		data() {
			return {
				// 未发布 审核中 已发布
				goodsType: 0,
				range: [{
						value: 0,
						text: "未发布"
					},
					{
						value: 1,
						text: "审核中"
					},
					{
						value: 2,
						text: "已发布"
					},
				],
				goodsList:[]
			}
		},
		methods: {
			loadGoodsList(goodsType) {
				getMyGoodsList(
				// {status: goodsType}
				).then(response => {
				  this.goodsList = response.data.rows
				})
			},
			change(e) {
				this.loadGoodsList(e)
			},
			formatCurrency(price) {
			      return `¥${price.toFixed(2)}`; // 例如：将 19.9 转为 "¥19.90"
			    }
		},
		mounted() {
			this.loadGoodsList()
		}
	}
</script>

<style>

</style>